package org.cbg.panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;

import javax.swing.*;

import com.tool.tcpimg.UIUtils;
import org.cbg.entity.Salegoods;
import org.cbg.frame.TrslationMainJframe;
import org.come.Frame.ZhuFrame;
import org.come.entity.RoleSummoning;
import org.come.until.AnalysisString;
import org.come.until.CutButtonImage;
import org.come.until.MessagrFlagUntil;
import org.come.until.UserMessUntil;

public class TraslationWantSendJishoushangpinFenleiZhaohuanshouModelJpanel extends JPanel {

    // 展示底框 展示图标 名字 等级
    private JLabel zhanshidikuang, zhangshi, mingzi, dengji;
    private BigDecimal rgid;

    public TraslationWantSendJishoushangpinFenleiZhaohuanshouModelJpanel(RoleSummoning pet) {
        // TODO Auto-generated constructor stub
        this.rgid = pet.getSid();
        this.setPreferredSize(new Dimension(310, 50));
        this.setOpaque(false);
        this.setLayout(null);

        zhanshidikuang = new JLabel();
        zhanshidikuang.setBorder(null);
        zhanshidikuang.setBounds(25, 5, 39, 39);
        zhanshidikuang.setIcon(CutButtonImage.getImage("inkImg/old/background/10.png", 39, 39));
        zhanshidikuang.setOpaque(false);
        this.add(zhanshidikuang);

        zhangshi = new JLabel();
        zhangshi.setBorder(null);
        zhangshi.setBounds(25, 5, 39, 39);
        zhangshi.setOpaque(false);
        this.add(zhangshi);

        mingzi = new JLabel();
        mingzi.setBorder(null);
        mingzi.setForeground(UIUtils.COLOR_cbg3);
        mingzi.setBounds(105, 5, 65, 39);
        mingzi.setOpaque(false);
        this.add(mingzi);

        dengji = new JLabel();
        dengji.setBorder(null);
        dengji.setBounds(305, 5, 55, 39);
        dengji.setForeground(UIUtils.COLOR_cbg6);
        dengji.setOpaque(false);
        this.add(dengji);
        chang(pet);
        this.addMouseListener(new gz());
    }

    class gz implements MouseListener {
        @Override
        public void mouseClicked(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
            Salegoods salegoods = new Salegoods();
            // 2大话币，3道具，5装备，6灵宝，4召唤兽
            RoleSummoning pet = UserMessUntil.getPetRgid(rgid);
            if (pet == null) {
                return;
            }
            salegoods.setSaletype(4);
            salegoods.setOtherid(pet.getSid());
            salegoods.setSalename(pet.getSummoningskin());
            salegoods.setSaleskin(pet.getSummoningskin());
            TraslationWantSendCardJpanel traslationWantSendCardJpanel = TrslationMainJframe.getTrslationMainJframe().getTrslationMainJpanel().getTranslationMainCardJpanel().getTraslationWantSentJpanel().getTraslationWantSendCardJpanel();
            traslationWantSendCardJpanel.getTraslationWantSendJishoushangpinJpanel()
                    .thGood(salegoods);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
            RoleSummoning pet = UserMessUntil.getPetRgid(rgid);
            if (pet == null) {
                return;
            }
            ZhuFrame.getZhuJpanel().creatpettext(pet);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            ZhuFrame.getZhuJpanel().pettext();
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        }

    }

    /** 图片更改 */
    public void chang(RoleSummoning pet) {
        ImageIcon icon1 = CutButtonImage.getCBG(4, pet.getSummoningskin(), 39, 39);
        zhangshi.setIcon(icon1);
        mingzi.setText(pet.getSummoningname());
        dengji.setText(AnalysisString.petLvl(pet.getGrade()));
    }

    public BigDecimal getRgid() {
        return rgid;
    }

    public void setRgid(BigDecimal rgid) {
        this.rgid = rgid;
    }

    public JLabel getZhanshidikuang() {
        return zhanshidikuang;
    }

    public void setZhanshidikuang(JLabel zhanshidikuang) {
        this.zhanshidikuang = zhanshidikuang;
    }

    public JLabel getZhangshi() {
        return zhangshi;
    }

    public void setZhangshi(JLabel zhangshi) {
        this.zhangshi = zhangshi;
    }

    public JLabel getMingzi() {
        return mingzi;
    }

    public void setMingzi(JLabel mingzi) {
        this.mingzi = mingzi;
    }

    public JLabel getDengji() {
        return dengji;
    }

    public void setDengji(JLabel dengji) {
        this.dengji = dengji;
    }

}
